﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RealtorsPortal.Business_Logic_Layer;
using System.Data;

namespace RealtorsPortal
{
    public partial class PropertyCategory : System.Web.UI.Page
    {
        AdvertisementsDAL advd = new AdvertisementsDAL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["cid"] != null)
                {
                    string cid = Request.QueryString["cid"].ToString();
                    this.LoadAndBindData(cid);
                }
                else
                {
                    Response.Redirect("Default.aspx");
                }
            }
        }

        private void LoadAndBindData(string cateId) {
            DataTable dt = advd.GetAdsByCateDataTable(cateId);
            lvwCateAds.DataSource = dt;
            lvwCateAds.DataBind();
            if (dt.Rows.Count>0)
            {
                lblCategoryName.Text = dt.Rows[0]["CategoryName"].ToString();
            }
        }
    }
}